package com.ufox.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {

    private Integer code;

    private String message;

    private Object data;

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Result ok(){
        return new Result(2000,"ok");
    }

    public static Result noLogin(){
        return new Result(401,"请先登录!");
    }


    public static Result ok(Object obj){
        return new Result(2000,"ok",obj);
    }

    public static Result error(){
        return new Result(999,"error");
    }



    public static Result error(String message){
        return new Result(999,message);
    }


    public static Result r(int rows){
        return  rows>0 ?   Result.ok() : Result.error();
    }

    public static Result r(boolean flag){
        return  flag ?   Result.ok() : Result.error();
    }
}
